package com.gujiangbo.chapter10;

import java.nio.ByteBuffer;
import java.util.Scanner;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/4/5 09:12
 * @Version: 1.0
 * @Description:Java 直接内存使用
 */
public class JavaDirectMemory {

    //1GB
    private static final int BUFFER = 1024 * 1024 * 1024;

    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BUFFER);
        System.out.println("直接内存分配完毕~");
        Scanner scanner = new Scanner(System.in);
        scanner.next();

        System.out.println("直接内存开始释放~");
        byteBuffer = null;
        System.gc();
        scanner.next();

    }
}
